<?php
  /**
   * @author EVANDRO DE OLIVEIRA.
   * @category VIEW
   * @package VIEWS/SCRIPTS/PAISES.
   * @since 17/06/2012.
   * @last_update 17/06/2012.
   * @copyright 2012.
   * @version 1.0.
   *
   */
?>
<script type="text/javascript">
  $(function(){
    $("input:text:eq(0):visible").focus();
  });
</script>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="content-view" id="teste">
  <tr>
    <td id="messenger" colspan="2"><?php echo $this->flashMessage();?></td>
  </tr>
  <tr>
    <td align="left" class="comp-title">CADASTRO DE <?php echo $this->strTitleP?></td>  
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="center" colspan="2" style="">
      <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%" class="content-form">
        <tr>
          <td class="space-bottom"></td>
        </tr>
        <tr>
          <td>
            <form name="form_add" method="post" action="" id="form_add">
              <table border="0" align="center" cellpadding="0" cellspacing="0">
                <?php 
//Core_Commons::debugging($this->arrColunas);                
                  foreach($this->arrColunas as $arrColunas){
                  	foreach($arrColunas as $strKey => $arrValues){ 
//Core_Commons::debugging($strKey);                  		              		
                  		if($strKey !== 'idCidade' && $strKey != 'dt_atualizacao'){
                  			switch($arrValues['DATA_TYPE']){
                      		case 'varchar':
                      			if($arrValues['LENGTH'] <= 5)
                      			  $intWidth = 50;
                      			elseif($arrValues['LENGTH'] > 5 && $arrValues['LENGTH'] <= 50)
                      				$intWidth = 120;
                      			else
                      		    $intWidth = 230;
                      			
                      			//$strCampo = '<input type="text" name="' . $strKey . '" id="' . $strKey . '" value="' . $this->request[$strKey] . '" style="width: ' . $intWidth . 'px;" maxlength="' . $arrValues['LENGTH'] . '"/>';
                      			$strCampo = $this->input('text', $strKey, $strKey , $this->request[$strKey], true, '', $arrValues['LENGTH'], '', "width: {$intWidth}px;");
                      		break;
                      		
                      		case 'smallint':
                      			$strCampo = $this->input('text', $strKey, $strKey , $this->request[$strKey], true, '', $arrValues['LENGTH'], '', "width: 50px;");
                          break;  
                      		
                          case 'int':
                      		case 'integer':
                            $strCampo = $this->dbComboBox($strKey, '', $this->strDaoModel, $this->strValue, utf8_encode($this->strLabel), '', 'Selecione');
                          break;
                          
                          case 'tinyint':
                          	$strCampo = $this->comboBox($strKey, '', array('1' => 'Ativo', '0' => 'Inativo'));
                          break;
                      		
                      		case 'date':
                      		case 'datetime':	
                      			$strCampo = $this->input('text', $strKey, $strKey , date("d/m/Y"), true, '', '', '10', "width: 80px;");
                      		break;
                      		
                      		default:
                      			$strCampo = $this->input('text', $strKey, $strKey , $this->request[$strKey], true, '', $arrValues['LENGTH'], '', "width: {$intWidth}px;");
                      		break;	
                      	}
                      	
                      	if(ereg('[_]', $strKey))
                      		$intStart = '3';
                      	else
                      		$intStart = '2';
                      	
                      	$strLabel = preg_replace('[cao]', 'ção', ucfirst(substr($strKey, $intStart))); 
                      	
                      	?>
                      	<tr>
                          <td align="right" class="label"><?php echo $strLabel?>:</td>  
                          <td align="left" class="space-bottom"><?php echo $strCampo?></td>                    	 
                      	</tr>
                      	<?php
                  	  }
                  	}
                  }
                ?>
                <tr>  
                  <td align="center" colspan="3">
                    <?php 
                      echo $this->input('button', 'cancel', 'boton', 'Cancelar', true, '', '', '', '', "onclick=\"window.location='list'\"");
                      echo'<span>&nbsp;</span>';
                      echo $this->input('submit', 'save', 'boton', 'Cadastrar', true);
                    ?>
                  </td>
                </tr>
              </table>
            </form>
          </td>
        </tr>
      </table>
    </td>
  </tr>  
</table>